#ifndef __COLLISION_H__
#define __COLLISION_H__

#include <vector>

#include "Global.h"
#include "Facade.h"
#include "Fichier.h"

class Facade;

class Collision
{
	public:

		Collision();
		Collision(Facade& oFacade);

		bool collisionLimitesMonde( int x, int y, SDL_Rect& recCol );

		void gererCollisionLimitesMonde( TInfoLink& infoLink );
		void gererCollision( int IDCarte, vector<unsigned char>& lstCollision, TInfoLink& infoLink );

		SDL_Rect* calculerPosTuile( int IDCarte, int x, int y );
		TypeTuile getTypeTuile( int x, int y, SDL_Rect& recCol );

		void update();

		~Collision();

	private:

		bool positionTemporaire( int IDCarte, vector<unsigned char>& lstCollision, TInfoLink& infoLink );
		void getTuiles( int IDCarte, TInfoLink& infoLink, SDL_Rect* tabTuiles[] );
		bool check_collision( TInfoLink& infoLink, SDL_Rect &recTuile, TypeCollision typeCol );
		bool collisionTuile( TInfoLink& infoLink, TInfoTuile& infoTuile );
		
		bool collisionRect( TRecCol RectA, TRecCol RectB, SDL_Rect& res, int deplacX, int deplacY );

		void initMatriceCollision();
		void resetMatriceCollision( TInfoTuile& infoTuile );

		int hautMondePixel, largMondePixel;
		int hautMonde, largMonde;
		int hautCarte, largCarte;

		vector<TInfoTuile> lstMatricesCol;

		Facade& oFacade;
};

#endif //__COLLISION_H__